package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbItemCatMapper;
import com.dongdongshop.pojo.TbItemCat;
import com.dongdongshop.pojo.TbItemCatExample;
import com.dongdongshop.service.TbItemCatServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class TbItemCatServiceImpl implements TbItemCatServiceI {

    @Autowired
    private TbItemCatMapper tbItemCatMapper;

    @Override
    @Transactional
    public List<TbItemCat> getFindAll(Long i) {
        TbItemCatExample example = new TbItemCatExample();
        TbItemCatExample.Criteria criteria = example.createCriteria();
        criteria.andParentIdEqualTo(i);
        return tbItemCatMapper.selectByExample(example);
    }

    @Override
    @Transactional
    public List<TbItemCat> nextLevel(Long pid) {
        TbItemCatExample example = new TbItemCatExample();
        TbItemCatExample.Criteria criteria = example.createCriteria();
        criteria.andParentIdEqualTo(pid);
        return tbItemCatMapper.selectByExample(example);
    }

    @Override
    @Transactional
    public TbItemCat getSelectById(Long id) {
        return tbItemCatMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional
    public void deleteTbItemCat(String id) {
        tbItemCatMapper.deleteTbItemCat(id);
    }

    @Override
    @Transactional
    public void saveTbItemCat(TbItemCat tbItemCat) {
        tbItemCatMapper.insertSelective(tbItemCat);
    }

    @Override
    @Transactional
    public TbItemCat toUpdateTbItemCat(Long id) {
        return tbItemCatMapper.selectByPrimaryKey(id);
    }

    @Override
    @Transactional
    public void updateTbItemCats(TbItemCat tbItemCat) {
        tbItemCatMapper.updateByPrimaryKeySelective(tbItemCat);
    }

    @Override
    public TbItemCat findtbItemCatByName(Long category1Id) {
        return tbItemCatMapper.selectByPrimaryKey(category1Id);
    }

    @Override
    public TbItemCat findtbItemCatByNames(Long category2Id) {
        return tbItemCatMapper.selectByPrimaryKey(category2Id);
    }

    @Override
    public TbItemCat findtbItemCatByNamess(Long category3Id) {
        return tbItemCatMapper.selectByPrimaryKey(category3Id);
    }
}
